package cn.com.nes.site.controller.product;

import cn.com.nes.site.entity.PageData;
import cn.com.nes.site.entity.vo.product.IsSblxNameplateConfigVO;
import cn.com.nes.site.service.product.IsSblxNameplateConfigService;
import cn.hutool.core.util.StrUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: ShenWei
 * @Date: 2024/04/02/10:32
 */
@Controller
@RequestMapping("/v2/product/nameplate")
public class IsSblxNameplateConfigController {
    @Resource
    IsSblxNameplateConfigService isSblxNameplateConfigService;

    /**
     * 批量保存铭牌信息
     * @param vo
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/saveNameplateList",method = RequestMethod.POST)
    public PageData saveNameplateList(@RequestBody IsSblxNameplateConfigVO vo){
        return isSblxNameplateConfigService.saveNameplateList(vo);
    }

    /**
     * 保存铭牌信息
     * @param vo
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/saveNameplate",method = RequestMethod.POST)
    public PageData saveNameplate(@RequestBody IsSblxNameplateConfigVO vo){
        return isSblxNameplateConfigService.saveNameplate(vo);
    }

    /**
     * 查询铭牌信息
     * @param vo
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/getNameplateInfo",method = RequestMethod.GET)
    public PageData getNameplateInfo(IsSblxNameplateConfigVO vo){
        if (StrUtil.isBlank(vo.getDeviceModelId())){
            return PageData.error("请传入产品能源类型id");
        }
        return isSblxNameplateConfigService.getNameplateInfo(vo);
    }

    /**
     * 删除铭牌信息
     * @param vo
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/delNameplate",method = RequestMethod.POST)
    public PageData delNameplate(@RequestBody IsSblxNameplateConfigVO vo){
        return isSblxNameplateConfigService.delNameplate(vo);
    }
}
